import { computed, onMounted, onUnmounted, ref } from "vue";
export default () => {
  const mainData = ref({});
  const handleDataChange = data => {
    mainData.value = data;
  };
  const receiveData = computed(() => {
    return mainData.value;
  });
  onMounted(() => {
    window.microApp && window.microApp.addDataListener(handleDataChange, true);
  });
  onUnmounted(() => {
    window.microApp && window.microApp.removeDataListener(handleDataChange);
  });
  return {
    receiveData
  };
};
